package com.test.controller.router;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.test.util.TokenProccessor;

/**
 * 
 * @ClassName: router 
 * @Description: [共用跳转类]
 * @author weiqi 
 * @date 2017年3月19日 下午6:42:53
 */
@Controller
public class router {
	/**
	 * 
	 * @Title: toMain 
	 * @Description: [main界面]
	 * @param @return
	 * @return String
	 * @throws
	 */
	@RequestMapping("/")
	public String toMain(){
		return "main";
	}
	
	@RequestMapping("/{root}/{page}")
	public String toPage(@PathVariable String root,@PathVariable String page, HttpServletRequest request){
		if (root.equals("user") && page.equals("user_login")) {
			//生成验证表单token
			String token = TokenProccessor.getInstance().makeToken();
			request.getSession().setAttribute("token", token);
		}
		request.getSession().setAttribute("url", root);
		return root+"/"+page;
	}
}
